# 和Httprequest相反
# HttpResponse是返回给浏览器的对象

# res = HttpResponse()

# res.content_type默认为html类型


# JsonResponse
# 能返回json数据
# 避免先转化为json格式，再去content_type = 'applcation/json'
# def jsons(request):
#     per = {
#         'a': 'sss',
#         'b': 'sssdsd'
#     }
#     return JsonResponse(per)

# 如果是列表里包字典
# 只需要在JsonResponse(safe=False)


# 生成csv
# def index(request):
#     res = HttpResponse(content_type='text/csv')
#     res['Content-Disposition'] = 'attachment; filename=abc.csv'
#     writer = csv.writer(res)
#     writer.writerow(['username', 'age'])
#     return res

# 大型csv用StreamingHttpResponse
# def large_csv(request):
#     res = StreamingHttpResponse(content_type='text/csv')
#     res['Content-Disposition'] = 'attachment; filename=large.csv'
#     res.streaming_content = ("username, age")
#     return res

